2 Cirrus Logic 5430 Controller Driver
4 Copyright (c) 2006 - 2007, Intel Corporation
5 All rights reserved. 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
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.
16 // Cirrus Logic 5430 Controller Driver
19 #ifndef _CIRRUS_LOGIC_5430_H_
20 #define _CIRRUS_LOGIC_5430_H_
24 #include <Protocol/UgaDraw.h>
25 #include <Protocol/GraphicsOutput.h>
26 #include <Protocol/PciIo.h>
27 #include <Protocol/DriverSupportedEfiVersion.h>
28 #include <Protocol/EdidOverride.h>
29 #include <Protocol/EdidDiscovered.h>
30 #include <Protocol/EdidActive.h>
31 #include <Protocol/DevicePath.h>
33 #include <Library/DebugLib.h>
34 #include <Library/UefiDriverEntryPoint.h>
35 #include <Library/UefiLib.h>
36 #include <Library/PcdLib.h>
37 #include <Library/MemoryAllocationLib.h>
38 #include <Library/UefiBootServicesTableLib.h>
39 #include <Library/BaseMemoryLib.h>
40 #include <Library/DevicePathLib.h>
41 #include <Library/DxeI2cLib.h>
43 #include <IndustryStandard/Pci22.h>
45 // Cirrus Logic 5430 PCI Configuration Header values
47 #define CIRRUS_LOGIC_VENDOR_ID 0x1013
48 #define CIRRUS_LOGIC_5430_DEVICE_ID 0x00a8
49 #define CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID 0x00a0
50 #define CIRRUS_LOGIC_5446_DEVICE_ID 0x00b8
53 // Cirrus Logic Graphical Mode Data
55 #define CIRRUS_LOGIC_5430_MODE_COUNT 3
59 UINT32 HorizontalResolution
;
60 UINT32 VerticalResolution
;
63 } CIRRUS_LOGIC_5430_MODE_DATA
;
65 #define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
68 // Cirrus Logic 5440 Private Data Structure
70 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('C', 'L', '5', '4')
75 EFI_PCI_IO_PROTOCOL
*PciIo
;
76 UINT64 OriginalPciAttributes
;
77 EFI_UGA_DRAW_PROTOCOL UgaDraw
;
78 EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput
;
79 EFI_EDID_DISCOVERED_PROTOCOL EdidDiscovered
;
80 EFI_EDID_ACTIVE_PROTOCOL EdidActive
;
81 EFI_DEVICE_PATH_PROTOCOL
*GopDevicePath
;
82 EFI_DEVICE_PATH_PROTOCOL
*UgaDevicePath
;
85 CIRRUS_LOGIC_5430_MODE_DATA ModeData
[CIRRUS_LOGIC_5430_MODE_COUNT
];
87 BOOLEAN HardwareNeedsStarting
;
88 } CIRRUS_LOGIC_5430_PRIVATE_DATA
;
91 /// Video Mode structure
101 } CIRRUS_LOGIC_5430_VIDEO_MODES
;
103 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS(a) \
104 CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, UgaDraw, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)
106 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS(a) \
107 CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, GraphicsOutput, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)
113 extern UINT8 AttributeController
[];
114 extern UINT8 GraphicsController
[];
115 extern UINT8 Crtc_640_480_256_60
[];
116 extern UINT16 Seq_640_480_256_60
[];
117 extern UINT8 Crtc_800_600_256_60
[];
118 extern UINT16 Seq_800_600_256_60
[];
119 extern UINT8 Crtc_1024_768_256_60
[];
120 extern UINT16 Seq_1024_768_256_60
[];
121 extern CIRRUS_LOGIC_5430_VIDEO_MODES CirrusLogic5430VideoModes
[];
122 extern EFI_DRIVER_BINDING_PROTOCOL gCirrusLogic5430DriverBinding
;
123 extern EFI_COMPONENT_NAME_PROTOCOL gCirrusLogic5430ComponentName
;
124 extern EFI_COMPONENT_NAME2_PROTOCOL gCirrusLogic5430ComponentName2
;
125 extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gCirrusLogic5430DriverSupportedEfiVersion
;
128 // Io Registers defined by VGA
130 #define CRTC_ADDRESS_REGISTER 0x3d4
131 #define CRTC_DATA_REGISTER 0x3d5
132 #define SEQ_ADDRESS_REGISTER 0x3c4
133 #define SEQ_DATA_REGISTER 0x3c5
134 #define GRAPH_ADDRESS_REGISTER 0x3ce
135 #define GRAPH_DATA_REGISTER 0x3cf
136 #define ATT_ADDRESS_REGISTER 0x3c0
137 #define MISC_OUTPUT_REGISTER 0x3c2
138 #define INPUT_STATUS_1_REGISTER 0x3da
139 #define DAC_PIXEL_MASK_REGISTER 0x3c6
140 #define PALETTE_INDEX_REGISTER 0x3c8
141 #define PALETTE_DATA_REGISTER 0x3c9
144 // UGA Draw Hardware abstraction internal worker functions
147 CirrusLogic5430UgaDrawConstructor (
148 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
152 CirrusLogic5430UgaDrawDestructor (
153 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
157 // Graphics Output Hardware abstraction internal worker functions
160 CirrusLogic5430GraphicsOutputConstructor (
161 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
165 CirrusLogic5430GraphicsOutputDestructor (
166 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
171 // EFI_DRIVER_BINDING_PROTOCOL Protocol Interface
174 TODO: Add function description
176 @param This TODO: add argument description
177 @param Controller TODO: add argument description
178 @param RemainingDevicePath TODO: add argument description
180 TODO: add return values
185 CirrusLogic5430ControllerDriverSupported (
186 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
187 IN EFI_HANDLE Controller
,
188 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
192 TODO: Add function description
194 @param This TODO: add argument description
195 @param Controller TODO: add argument description
196 @param RemainingDevicePath TODO: add argument description
198 TODO: add return values
203 CirrusLogic5430ControllerDriverStart (
204 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
205 IN EFI_HANDLE Controller
,
206 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
210 TODO: Add function description
212 @param This TODO: add argument description
213 @param Controller TODO: add argument description
214 @param NumberOfChildren TODO: add argument description
215 @param ChildHandleBuffer TODO: add argument description
217 TODO: add return values
222 CirrusLogic5430ControllerDriverStop (
223 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
224 IN EFI_HANDLE Controller
,
225 IN UINTN NumberOfChildren
,
226 IN EFI_HANDLE
*ChildHandleBuffer
230 // EFI Component Name Functions
233 Retrieves a Unicode string that is the user readable name of the driver.
235 This function retrieves the user readable name of a driver in the form of a
236 Unicode string. If the driver specified by This has a user readable name in
237 the language specified by Language, then a pointer to the driver name is
238 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
239 by This does not support the language specified by Language,
240 then EFI_UNSUPPORTED is returned.
242 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
243 EFI_COMPONENT_NAME_PROTOCOL instance.
245 @param Language[in] A pointer to a Null-terminated ASCII string
246 array indicating the language. This is the
247 language of the driver name that the caller is
248 requesting, and it must match one of the
249 languages specified in SupportedLanguages. The
250 number of languages supported by a driver is up
251 to the driver writer. Language is specified
252 in RFC 3066 or ISO 639-2 language code format.
254 @param DriverName[out] A pointer to the Unicode string to return.
255 This Unicode string is the name of the
256 driver specified by This in the language
257 specified by Language.
259 @retval EFI_SUCCESS The Unicode string for the Driver specified by
260 This and the language specified by Language was
261 returned in DriverName.
263 @retval EFI_INVALID_PARAMETER Language is NULL.
265 @retval EFI_INVALID_PARAMETER DriverName is NULL.
267 @retval EFI_UNSUPPORTED The driver specified by This does not support
268 the language specified by Language.
273 CirrusLogic5430ComponentNameGetDriverName (
274 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
276 OUT CHAR16
**DriverName
281 Retrieves a Unicode string that is the user readable name of the controller
282 that is being managed by a driver.
284 This function retrieves the user readable name of the controller specified by
285 ControllerHandle and ChildHandle in the form of a Unicode string. If the
286 driver specified by This has a user readable name in the language specified by
287 Language, then a pointer to the controller name is returned in ControllerName,
288 and EFI_SUCCESS is returned. If the driver specified by This is not currently
289 managing the controller specified by ControllerHandle and ChildHandle,
290 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
291 support the language specified by Language, then EFI_UNSUPPORTED is returned.
293 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
294 EFI_COMPONENT_NAME_PROTOCOL instance.
296 @param ControllerHandle[in] The handle of a controller that the driver
297 specified by This is managing. This handle
298 specifies the controller whose name is to be
301 @param ChildHandle[in] The handle of the child controller to retrieve
302 the name of. This is an optional parameter that
303 may be NULL. It will be NULL for device
304 drivers. It will also be NULL for a bus drivers
305 that wish to retrieve the name of the bus
306 controller. It will not be NULL for a bus
307 driver that wishes to retrieve the name of a
310 @param Language[in] A pointer to a Null-terminated ASCII string
311 array indicating the language. This is the
312 language of the driver name that the caller is
313 requesting, and it must match one of the
314 languages specified in SupportedLanguages. The
315 number of languages supported by a driver is up
316 to the driver writer. Language is specified in
317 RFC 3066 or ISO 639-2 language code format.
319 @param ControllerName[out] A pointer to the Unicode string to return.
320 This Unicode string is the name of the
321 controller specified by ControllerHandle and
322 ChildHandle in the language specified by
323 Language from the point of view of the driver
326 @retval EFI_SUCCESS The Unicode string for the user readable name in
327 the language specified by Language for the
328 driver specified by This was returned in
331 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
333 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
336 @retval EFI_INVALID_PARAMETER Language is NULL.
338 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
340 @retval EFI_UNSUPPORTED The driver specified by This is not currently
341 managing the controller specified by
342 ControllerHandle and ChildHandle.
344 @retval EFI_UNSUPPORTED The driver specified by This does not support
345 the language specified by Language.
350 CirrusLogic5430ComponentNameGetControllerName (
351 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
352 IN EFI_HANDLE ControllerHandle
,
353 IN EFI_HANDLE ChildHandle OPTIONAL
,
355 OUT CHAR16
**ControllerName
360 // Local Function Prototypes
363 InitializeGraphicsMode (
364 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
365 CIRRUS_LOGIC_5430_VIDEO_MODES
*ModeData
370 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
379 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
384 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
391 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
398 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
405 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
411 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
416 CirrusLogic5430VideoModeSetup (
417 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private