2 Cirrus Logic 5430 Controller Driver
\r
4 Copyright (c) 2006 - 2007, Intel Corporation
\r
5 All rights reserved. This program and the accompanying materials
\r
6 are licensed and made available under the terms and conditions of the BSD License
\r
7 which accompanies this distribution. The full text of the license may be found at
\r
8 http://opensource.org/licenses/bsd-license.php
\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
\r
16 // Cirrus Logic 5430 Controller Driver
\r
19 #ifndef _CIRRUS_LOGIC_5430_H_
\r
20 #define _CIRRUS_LOGIC_5430_H_
\r
24 #include <Protocol/UgaDraw.h>
\r
25 #include <Protocol/GraphicsOutput.h>
\r
26 #include <Protocol/PciIo.h>
\r
27 #include <Protocol/DriverSupportedEfiVersion.h>
\r
28 #include <Protocol/EdidOverride.h>
\r
29 #include <Protocol/EdidDiscovered.h>
\r
30 #include <Protocol/EdidActive.h>
\r
31 #include <Protocol/DevicePath.h>
\r
33 #include <Library/DebugLib.h>
\r
34 #include <Library/UefiDriverEntryPoint.h>
\r
35 #include <Library/UefiLib.h>
\r
36 #include <Library/PcdLib.h>
\r
37 #include <Library/MemoryAllocationLib.h>
\r
38 #include <Library/UefiBootServicesTableLib.h>
\r
39 #include <Library/BaseMemoryLib.h>
\r
40 #include <Library/DevicePathLib.h>
\r
41 #include <Library/DxeI2cLib.h>
\r
43 #include <IndustryStandard/pci22.h>
\r
45 // Cirrus Logic 5430 PCI Configuration Header values
\r
47 #define CIRRUS_LOGIC_VENDOR_ID 0x1013
\r
48 #define CIRRUS_LOGIC_5430_DEVICE_ID 0x00a8
\r
49 #define CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID 0x00a0
\r
50 #define CIRRUS_LOGIC_5446_DEVICE_ID 0x00b8
\r
53 // Cirrus Logic Graphical Mode Data
\r
55 #define CIRRUS_LOGIC_5430_MODE_COUNT 3
\r
59 UINT32 HorizontalResolution;
\r
60 UINT32 VerticalResolution;
\r
63 } CIRRUS_LOGIC_5430_MODE_DATA;
\r
65 #define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
\r
68 // Cirrus Logic 5440 Private Data Structure
\r
70 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('C', 'L', '5', '4')
\r
75 EFI_PCI_IO_PROTOCOL *PciIo;
\r
76 UINT64 OriginalPciAttributes;
\r
77 EFI_UGA_DRAW_PROTOCOL UgaDraw;
\r
78 EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
\r
79 EFI_EDID_DISCOVERED_PROTOCOL EdidDiscovered;
\r
80 EFI_EDID_ACTIVE_PROTOCOL EdidActive;
\r
81 EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
\r
82 EFI_DEVICE_PATH_PROTOCOL *UgaDevicePath;
\r
85 CIRRUS_LOGIC_5430_MODE_DATA ModeData[CIRRUS_LOGIC_5430_MODE_COUNT];
\r
87 BOOLEAN HardwareNeedsStarting;
\r
88 } CIRRUS_LOGIC_5430_PRIVATE_DATA;
\r
91 /// Video Mode structure
\r
98 UINT8 *CrtcSettings;
\r
99 UINT16 *SeqSettings;
\r
101 } CIRRUS_LOGIC_5430_VIDEO_MODES;
\r
103 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS(a) \
\r
104 CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, UgaDraw, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)
\r
106 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS(a) \
\r
107 CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, GraphicsOutput, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)
\r
111 // Global Variables
\r
113 extern UINT8 AttributeController[];
\r
114 extern UINT8 GraphicsController[];
\r
115 extern UINT8 Crtc_640_480_256_60[];
\r
116 extern UINT16 Seq_640_480_256_60[];
\r
117 extern UINT8 Crtc_800_600_256_60[];
\r
118 extern UINT16 Seq_800_600_256_60[];
\r
119 extern UINT8 Crtc_1024_768_256_60[];
\r
120 extern UINT16 Seq_1024_768_256_60[];
\r
121 extern CIRRUS_LOGIC_5430_VIDEO_MODES CirrusLogic5430VideoModes[];
\r
122 extern EFI_DRIVER_BINDING_PROTOCOL gCirrusLogic5430DriverBinding;
\r
123 extern EFI_COMPONENT_NAME_PROTOCOL gCirrusLogic5430ComponentName;
\r
124 extern EFI_COMPONENT_NAME2_PROTOCOL gCirrusLogic5430ComponentName2;
\r
125 extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gCirrusLogic5430DriverSupportedEfiVersion;
\r
128 // Io Registers defined by VGA
\r
130 #define CRTC_ADDRESS_REGISTER 0x3d4
\r
131 #define CRTC_DATA_REGISTER 0x3d5
\r
132 #define SEQ_ADDRESS_REGISTER 0x3c4
\r
133 #define SEQ_DATA_REGISTER 0x3c5
\r
134 #define GRAPH_ADDRESS_REGISTER 0x3ce
\r
135 #define GRAPH_DATA_REGISTER 0x3cf
\r
136 #define ATT_ADDRESS_REGISTER 0x3c0
\r
137 #define MISC_OUTPUT_REGISTER 0x3c2
\r
138 #define INPUT_STATUS_1_REGISTER 0x3da
\r
139 #define DAC_PIXEL_MASK_REGISTER 0x3c6
\r
140 #define PALETTE_INDEX_REGISTER 0x3c8
\r
141 #define PALETTE_DATA_REGISTER 0x3c9
\r
143 #define ACPI_ADR_DISPLAY_TYPE_VGA 1
\r
145 #define ACPI_DISPLAY_ADR(_DeviceIdScheme, _HeadId, _NonVgaOutput, _BiosCanDetect, _VendorInfo, _Type, _Port, _Index) \
\r
146 ((UINT32) ( (((_DeviceIdScheme) & 0x1) << 31) | \
\r
147 (((_HeadId) & 0x7) << 18) | \
\r
148 (((_NonVgaOutput) & 0x1) << 17) | \
\r
149 (((_BiosCanDetect) & 0x1) << 16) | \
\r
150 (((_VendorInfo) & 0xf) << 12) | \
\r
151 (((_Type) & 0xf) << 8) | \
\r
152 (((_Port) & 0xf) << 4) | \
\r
153 ((_Index) & 0xf) ))
\r
156 // UGA Draw Hardware abstraction internal worker functions
\r
159 CirrusLogic5430UgaDrawConstructor (
\r
160 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
\r
165 CirrusLogic5430UgaDrawDestructor (
\r
166 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
\r
171 // Graphics Output Hardware abstraction internal worker functions
\r
174 CirrusLogic5430GraphicsOutputConstructor (
\r
175 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
\r
180 CirrusLogic5430GraphicsOutputDestructor (
\r
181 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
\r
187 // EFI_DRIVER_BINDING_PROTOCOL Protocol Interface
\r
190 TODO: Add function description
\r
192 @param This TODO: add argument description
\r
193 @param Controller TODO: add argument description
\r
194 @param RemainingDevicePath TODO: add argument description
\r
196 TODO: add return values
\r
201 CirrusLogic5430ControllerDriverSupported (
\r
202 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
203 IN EFI_HANDLE Controller,
\r
204 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
\r
209 TODO: Add function description
\r
211 @param This TODO: add argument description
\r
212 @param Controller TODO: add argument description
\r
213 @param RemainingDevicePath TODO: add argument description
\r
215 TODO: add return values
\r
220 CirrusLogic5430ControllerDriverStart (
\r
221 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
222 IN EFI_HANDLE Controller,
\r
223 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
\r
228 TODO: Add function description
\r
230 @param This TODO: add argument description
\r
231 @param Controller TODO: add argument description
\r
232 @param NumberOfChildren TODO: add argument description
\r
233 @param ChildHandleBuffer TODO: add argument description
\r
235 TODO: add return values
\r
240 CirrusLogic5430ControllerDriverStop (
\r
241 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
242 IN EFI_HANDLE Controller,
\r
243 IN UINTN NumberOfChildren,
\r
244 IN EFI_HANDLE *ChildHandleBuffer
\r
249 // EFI Component Name Functions
\r
252 Retrieves a Unicode string that is the user readable name of the driver.
\r
254 This function retrieves the user readable name of a driver in the form of a
\r
255 Unicode string. If the driver specified by This has a user readable name in
\r
256 the language specified by Language, then a pointer to the driver name is
\r
257 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
\r
258 by This does not support the language specified by Language,
\r
259 then EFI_UNSUPPORTED is returned.
\r
261 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
\r
262 EFI_COMPONENT_NAME_PROTOCOL instance.
\r
264 @param Language[in] A pointer to a Null-terminated ASCII string
\r
265 array indicating the language. This is the
\r
266 language of the driver name that the caller is
\r
267 requesting, and it must match one of the
\r
268 languages specified in SupportedLanguages. The
\r
269 number of languages supported by a driver is up
\r
270 to the driver writer. Language is specified
\r
271 in RFC 3066 or ISO 639-2 language code format.
\r
273 @param DriverName[out] A pointer to the Unicode string to return.
\r
274 This Unicode string is the name of the
\r
275 driver specified by This in the language
\r
276 specified by Language.
\r
278 @retval EFI_SUCCESS The Unicode string for the Driver specified by
\r
279 This and the language specified by Language was
\r
280 returned in DriverName.
\r
282 @retval EFI_INVALID_PARAMETER Language is NULL.
\r
284 @retval EFI_INVALID_PARAMETER DriverName is NULL.
\r
286 @retval EFI_UNSUPPORTED The driver specified by This does not support
\r
287 the language specified by Language.
\r
292 CirrusLogic5430ComponentNameGetDriverName (
\r
293 IN EFI_COMPONENT_NAME_PROTOCOL *This,
\r
294 IN CHAR8 *Language,
\r
295 OUT CHAR16 **DriverName
\r
300 Retrieves a Unicode string that is the user readable name of the controller
\r
301 that is being managed by a driver.
\r
303 This function retrieves the user readable name of the controller specified by
\r
304 ControllerHandle and ChildHandle in the form of a Unicode string. If the
\r
305 driver specified by This has a user readable name in the language specified by
\r
306 Language, then a pointer to the controller name is returned in ControllerName,
\r
307 and EFI_SUCCESS is returned. If the driver specified by This is not currently
\r
308 managing the controller specified by ControllerHandle and ChildHandle,
\r
309 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
\r
310 support the language specified by Language, then EFI_UNSUPPORTED is returned.
\r
312 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
\r
313 EFI_COMPONENT_NAME_PROTOCOL instance.
\r
315 @param ControllerHandle[in] The handle of a controller that the driver
\r
316 specified by This is managing. This handle
\r
317 specifies the controller whose name is to be
\r
320 @param ChildHandle[in] The handle of the child controller to retrieve
\r
321 the name of. This is an optional parameter that
\r
322 may be NULL. It will be NULL for device
\r
323 drivers. It will also be NULL for a bus drivers
\r
324 that wish to retrieve the name of the bus
\r
325 controller. It will not be NULL for a bus
\r
326 driver that wishes to retrieve the name of a
\r
329 @param Language[in] A pointer to a Null-terminated ASCII string
\r
330 array indicating the language. This is the
\r
331 language of the driver name that the caller is
\r
332 requesting, and it must match one of the
\r
333 languages specified in SupportedLanguages. The
\r
334 number of languages supported by a driver is up
\r
335 to the driver writer. Language is specified in
\r
336 RFC 3066 or ISO 639-2 language code format.
\r
338 @param ControllerName[out] A pointer to the Unicode string to return.
\r
339 This Unicode string is the name of the
\r
340 controller specified by ControllerHandle and
\r
341 ChildHandle in the language specified by
\r
342 Language from the point of view of the driver
\r
345 @retval EFI_SUCCESS The Unicode string for the user readable name in
\r
346 the language specified by Language for the
\r
347 driver specified by This was returned in
\r
350 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
\r
352 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
\r
355 @retval EFI_INVALID_PARAMETER Language is NULL.
\r
357 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
\r
359 @retval EFI_UNSUPPORTED The driver specified by This is not currently
\r
360 managing the controller specified by
\r
361 ControllerHandle and ChildHandle.
\r
363 @retval EFI_UNSUPPORTED The driver specified by This does not support
\r
364 the language specified by Language.
\r
369 CirrusLogic5430ComponentNameGetControllerName (
\r
370 IN EFI_COMPONENT_NAME_PROTOCOL *This,
\r
371 IN EFI_HANDLE ControllerHandle,
\r
372 IN EFI_HANDLE ChildHandle OPTIONAL,
\r
373 IN CHAR8 *Language,
\r
374 OUT CHAR16 **ControllerName
\r
379 // Local Function Prototypes
\r
382 InitializeGraphicsMode (
\r
383 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
384 CIRRUS_LOGIC_5430_VIDEO_MODES *ModeData
\r
389 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
397 SetDefaultPalette (
\r
398 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
\r
403 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
410 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
417 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
424 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
430 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
435 CirrusLogic5430VideoModeSetup (
\r
436 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
\r