2 Cirrus Logic 5430 Controller Driver
\r
4 Copyright (c) 2006, 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
29 #include <Library/DebugLib.h>
\r
30 #include <Library/UefiDriverEntryPoint.h>
\r
31 #include <Library/UefiLib.h>
\r
32 #include <Library/PcdLib.h>
\r
33 #include <Library/MemoryAllocationLib.h>
\r
34 #include <Library/UefiBootServicesTableLib.h>
\r
36 #include <IndustryStandard/pci22.h>
\r
38 // Cirrus Logic 5430 PCI Configuration Header values
\r
40 #define CIRRUS_LOGIC_VENDOR_ID 0x1013
\r
41 #define CIRRUS_LOGIC_5430_DEVICE_ID 0x00a8
\r
42 #define CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID 0x00a0
\r
43 #define CIRRUS_LOGIC_5446_DEVICE_ID 0x00b8
\r
46 // Cirrus Logic Graphical Mode Data
\r
48 #define CIRRUS_LOGIC_5430_MODE_COUNT 3
\r
51 UINT32 HorizontalResolution;
\r
52 UINT32 VerticalResolution;
\r
55 } CIRRUS_LOGIC_5430_MODE_DATA;
\r
57 #define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
\r
60 // Cirrus Logic 5440 Private Data Structure
\r
62 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('C', 'L', '5', '4')
\r
67 EFI_PCI_IO_PROTOCOL *PciIo;
\r
68 UINT64 OriginalPciAttributes;
\r
69 EFI_UGA_DRAW_PROTOCOL UgaDraw;
\r
70 EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
\r
73 CIRRUS_LOGIC_5430_MODE_DATA ModeData[CIRRUS_LOGIC_5430_MODE_COUNT];
\r
75 BOOLEAN HardwareNeedsStarting;
\r
76 } CIRRUS_LOGIC_5430_PRIVATE_DATA;
\r
79 /// Video Mode structure
\r
86 UINT8 *CrtcSettings;
\r
87 UINT16 *SeqSettings;
\r
89 } CIRRUS_LOGIC_5430_VIDEO_MODES;
\r
91 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS(a) \
\r
92 CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, UgaDraw, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)
\r
94 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS(a) \
\r
95 CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, GraphicsOutput, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)
\r
101 extern UINT8 AttributeController[];
\r
102 extern UINT8 GraphicsController[];
\r
103 extern UINT8 Crtc_640_480_256_60[];
\r
104 extern UINT16 Seq_640_480_256_60[];
\r
105 extern UINT8 Crtc_800_600_256_60[];
\r
106 extern UINT16 Seq_800_600_256_60[];
\r
107 extern UINT8 Crtc_1024_768_256_60[];
\r
108 extern UINT16 Seq_1024_768_256_60[];
\r
109 extern CIRRUS_LOGIC_5430_VIDEO_MODES CirrusLogic5430VideoModes[];
\r
110 extern EFI_DRIVER_BINDING_PROTOCOL gCirrusLogic5430DriverBinding;
\r
111 extern EFI_COMPONENT_NAME_PROTOCOL gCirrusLogic5430ComponentName;
\r
112 extern EFI_COMPONENT_NAME2_PROTOCOL gCirrusLogic5430ComponentName2;
\r
113 extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gCirrusLogic5430DriverSupportedEfiVersion;
\r
116 // Io Registers defined by VGA
\r
118 #define CRTC_ADDRESS_REGISTER 0x3d4
\r
119 #define CRTC_DATA_REGISTER 0x3d5
\r
120 #define SEQ_ADDRESS_REGISTER 0x3c4
\r
121 #define SEQ_DATA_REGISTER 0x3c5
\r
122 #define GRAPH_ADDRESS_REGISTER 0x3ce
\r
123 #define GRAPH_DATA_REGISTER 0x3cf
\r
124 #define ATT_ADDRESS_REGISTER 0x3c0
\r
125 #define MISC_OUTPUT_REGISTER 0x3c2
\r
126 #define INPUT_STATUS_1_REGISTER 0x3da
\r
127 #define DAC_PIXEL_MASK_REGISTER 0x3c6
\r
128 #define PALETTE_INDEX_REGISTER 0x3c8
\r
129 #define PALETTE_DATA_REGISTER 0x3c9
\r
132 // UGA Draw Hardware abstraction internal worker functions
\r
135 CirrusLogic5430UgaDrawConstructor (
\r
136 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
\r
141 CirrusLogic5430UgaDrawDestructor (
\r
142 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
\r
147 // Graphics Output Hardware abstraction internal worker functions
\r
150 CirrusLogic5430GraphicsOutputConstructor (
\r
151 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
\r
156 CirrusLogic5430GraphicsOutputDestructor (
\r
157 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
\r
163 // EFI_DRIVER_BINDING_PROTOCOL Protocol Interface
\r
166 TODO: Add function description
\r
168 @param This TODO: add argument description
\r
169 @param Controller TODO: add argument description
\r
170 @param RemainingDevicePath TODO: add argument description
\r
172 TODO: add return values
\r
177 CirrusLogic5430ControllerDriverSupported (
\r
178 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
179 IN EFI_HANDLE Controller,
\r
180 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
\r
185 TODO: Add function description
\r
187 @param This TODO: add argument description
\r
188 @param Controller TODO: add argument description
\r
189 @param RemainingDevicePath TODO: add argument description
\r
191 TODO: add return values
\r
196 CirrusLogic5430ControllerDriverStart (
\r
197 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
198 IN EFI_HANDLE Controller,
\r
199 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
\r
204 TODO: Add function description
\r
206 @param This TODO: add argument description
\r
207 @param Controller TODO: add argument description
\r
208 @param NumberOfChildren TODO: add argument description
\r
209 @param ChildHandleBuffer TODO: add argument description
\r
211 TODO: add return values
\r
216 CirrusLogic5430ControllerDriverStop (
\r
217 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
218 IN EFI_HANDLE Controller,
\r
219 IN UINTN NumberOfChildren,
\r
220 IN EFI_HANDLE *ChildHandleBuffer
\r
225 // EFI Component Name Functions
\r
228 Retrieves a Unicode string that is the user readable name of the driver.
\r
230 This function retrieves the user readable name of a driver in the form of a
\r
231 Unicode string. If the driver specified by This has a user readable name in
\r
232 the language specified by Language, then a pointer to the driver name is
\r
233 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
\r
234 by This does not support the language specified by Language,
\r
235 then EFI_UNSUPPORTED is returned.
\r
237 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
\r
238 EFI_COMPONENT_NAME_PROTOCOL instance.
\r
240 @param Language[in] A pointer to a Null-terminated ASCII string
\r
241 array indicating the language. This is the
\r
242 language of the driver name that the caller is
\r
243 requesting, and it must match one of the
\r
244 languages specified in SupportedLanguages. The
\r
245 number of languages supported by a driver is up
\r
246 to the driver writer. Language is specified
\r
247 in RFC 3066 or ISO 639-2 language code format.
\r
249 @param DriverName[out] A pointer to the Unicode string to return.
\r
250 This Unicode string is the name of the
\r
251 driver specified by This in the language
\r
252 specified by Language.
\r
254 @retval EFI_SUCCESS The Unicode string for the Driver specified by
\r
255 This and the language specified by Language was
\r
256 returned in DriverName.
\r
258 @retval EFI_INVALID_PARAMETER Language is NULL.
\r
260 @retval EFI_INVALID_PARAMETER DriverName is NULL.
\r
262 @retval EFI_UNSUPPORTED The driver specified by This does not support
\r
263 the language specified by Language.
\r
268 CirrusLogic5430ComponentNameGetDriverName (
\r
269 IN EFI_COMPONENT_NAME_PROTOCOL *This,
\r
270 IN CHAR8 *Language,
\r
271 OUT CHAR16 **DriverName
\r
276 Retrieves a Unicode string that is the user readable name of the controller
\r
277 that is being managed by a driver.
\r
279 This function retrieves the user readable name of the controller specified by
\r
280 ControllerHandle and ChildHandle in the form of a Unicode string. If the
\r
281 driver specified by This has a user readable name in the language specified by
\r
282 Language, then a pointer to the controller name is returned in ControllerName,
\r
283 and EFI_SUCCESS is returned. If the driver specified by This is not currently
\r
284 managing the controller specified by ControllerHandle and ChildHandle,
\r
285 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
\r
286 support the language specified by Language, then EFI_UNSUPPORTED is returned.
\r
288 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
\r
289 EFI_COMPONENT_NAME_PROTOCOL instance.
\r
291 @param ControllerHandle[in] The handle of a controller that the driver
\r
292 specified by This is managing. This handle
\r
293 specifies the controller whose name is to be
\r
296 @param ChildHandle[in] The handle of the child controller to retrieve
\r
297 the name of. This is an optional parameter that
\r
298 may be NULL. It will be NULL for device
\r
299 drivers. It will also be NULL for a bus drivers
\r
300 that wish to retrieve the name of the bus
\r
301 controller. It will not be NULL for a bus
\r
302 driver that wishes to retrieve the name of a
\r
305 @param Language[in] A pointer to a Null-terminated ASCII string
\r
306 array indicating the language. This is the
\r
307 language of the driver name that the caller is
\r
308 requesting, and it must match one of the
\r
309 languages specified in SupportedLanguages. The
\r
310 number of languages supported by a driver is up
\r
311 to the driver writer. Language is specified in
\r
312 RFC 3066 or ISO 639-2 language code format.
\r
314 @param ControllerName[out] A pointer to the Unicode string to return.
\r
315 This Unicode string is the name of the
\r
316 controller specified by ControllerHandle and
\r
317 ChildHandle in the language specified by
\r
318 Language from the point of view of the driver
\r
321 @retval EFI_SUCCESS The Unicode string for the user readable name in
\r
322 the language specified by Language for the
\r
323 driver specified by This was returned in
\r
326 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
\r
328 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
\r
331 @retval EFI_INVALID_PARAMETER Language is NULL.
\r
333 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
\r
335 @retval EFI_UNSUPPORTED The driver specified by This is not currently
\r
336 managing the controller specified by
\r
337 ControllerHandle and ChildHandle.
\r
339 @retval EFI_UNSUPPORTED The driver specified by This does not support
\r
340 the language specified by Language.
\r
345 CirrusLogic5430ComponentNameGetControllerName (
\r
346 IN EFI_COMPONENT_NAME_PROTOCOL *This,
\r
347 IN EFI_HANDLE ControllerHandle,
\r
348 IN EFI_HANDLE ChildHandle OPTIONAL,
\r
349 IN CHAR8 *Language,
\r
350 OUT CHAR16 **ControllerName
\r
355 // Local Function Prototypes
\r
358 InitializeGraphicsMode (
\r
359 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
360 CIRRUS_LOGIC_5430_VIDEO_MODES *ModeData
\r
365 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
373 SetDefaultPalette (
\r
374 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
\r
379 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
386 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
393 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
400 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r
406 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
\r