]>
Commit | Line | Data |
---|---|---|
87f8ccbe | 1 | /** @file\r |
2 | Cirrus Logic 5430 Controller Driver\r | |
3 | \r | |
31f9e631 | 4 | Copyright (c) 2006 - 2007, Intel Corporation\r |
94b73c24 | 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 | |
87f8ccbe | 9 | \r |
94b73c24 | 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 | |
87f8ccbe | 12 | \r |
13 | **/\r | |
14 | \r | |
15 | //\r | |
16 | // Cirrus Logic 5430 Controller Driver\r | |
17 | //\r | |
18 | \r | |
19 | #ifndef _CIRRUS_LOGIC_5430_H_\r | |
20 | #define _CIRRUS_LOGIC_5430_H_\r | |
21 | \r | |
22 | \r | |
23 | #include <Uefi.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 | |
31f9e631 | 28 | #include <Protocol/EdidOverride.h>\r |
29 | #include <Protocol/EdidDiscovered.h>\r | |
30 | #include <Protocol/EdidActive.h>\r | |
31 | #include <Protocol/DevicePath.h>\r | |
87f8ccbe | 32 | \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 | |
31f9e631 | 39 | #include <Library/BaseMemoryLib.h>\r |
40 | #include <Library/DevicePathLib.h>\r | |
41 | #include <Library/DxeI2cLib.h>\r | |
87f8ccbe | 42 | \r |
93da4b6b | 43 | #include <IndustryStandard/Pci22.h>\r |
87f8ccbe | 44 | //\r |
45 | // Cirrus Logic 5430 PCI Configuration Header values\r | |
46 | //\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 | |
51 | \r | |
52 | //\r | |
53 | // Cirrus Logic Graphical Mode Data\r | |
54 | //\r | |
55 | #define CIRRUS_LOGIC_5430_MODE_COUNT 3\r | |
56 | \r | |
57 | typedef struct {\r | |
31f9e631 | 58 | UINT32 ModeNumber;\r |
87f8ccbe | 59 | UINT32 HorizontalResolution;\r |
60 | UINT32 VerticalResolution;\r | |
61 | UINT32 ColorDepth;\r | |
62 | UINT32 RefreshRate;\r | |
63 | } CIRRUS_LOGIC_5430_MODE_DATA;\r | |
64 | \r | |
65 | #define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff\r | |
66 | \r | |
67 | //\r | |
68 | // Cirrus Logic 5440 Private Data Structure\r | |
69 | //\r | |
70 | #define CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('C', 'L', '5', '4')\r | |
71 | \r | |
72 | typedef struct {\r | |
73 | UINT64 Signature;\r | |
74 | EFI_HANDLE Handle;\r | |
75 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
94b73c24 | 76 | UINT64 OriginalPciAttributes;\r |
87f8ccbe | 77 | EFI_UGA_DRAW_PROTOCOL UgaDraw;\r |
78 | EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;\r | |
31f9e631 | 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 | |
87f8ccbe | 83 | UINTN CurrentMode;\r |
84 | UINTN MaxMode;\r | |
85 | CIRRUS_LOGIC_5430_MODE_DATA ModeData[CIRRUS_LOGIC_5430_MODE_COUNT];\r | |
86 | UINT8 *LineBuffer;\r | |
87 | BOOLEAN HardwareNeedsStarting;\r | |
88 | } CIRRUS_LOGIC_5430_PRIVATE_DATA;\r | |
89 | \r | |
90 | ///\r | |
91 | /// Video Mode structure\r | |
92 | ///\r | |
93 | typedef struct {\r | |
94 | UINT32 Width;\r | |
95 | UINT32 Height;\r | |
96 | UINT32 ColorDepth;\r | |
97 | UINT32 RefreshRate;\r | |
98 | UINT8 *CrtcSettings;\r | |
99 | UINT16 *SeqSettings;\r | |
100 | UINT8 MiscSetting;\r | |
101 | } CIRRUS_LOGIC_5430_VIDEO_MODES;\r | |
102 | \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 | |
105 | \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 | |
108 | \r | |
109 | \r | |
110 | //\r | |
111 | // Global Variables\r | |
112 | //\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 | |
126 | \r | |
127 | //\r | |
128 | // Io Registers defined by VGA\r | |
129 | //\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 | |
142 | \r | |
143 | //\r | |
144 | // UGA Draw Hardware abstraction internal worker functions\r | |
145 | //\r | |
146 | EFI_STATUS\r | |
147 | CirrusLogic5430UgaDrawConstructor (\r | |
148 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r | |
149 | )\r | |
150 | ;\r | |
151 | \r | |
152 | EFI_STATUS\r | |
153 | CirrusLogic5430UgaDrawDestructor (\r | |
154 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r | |
155 | )\r | |
156 | ;\r | |
157 | \r | |
158 | //\r | |
159 | // Graphics Output Hardware abstraction internal worker functions\r | |
160 | //\r | |
161 | EFI_STATUS\r | |
162 | CirrusLogic5430GraphicsOutputConstructor (\r | |
163 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r | |
164 | )\r | |
165 | ;\r | |
166 | \r | |
167 | EFI_STATUS\r | |
168 | CirrusLogic5430GraphicsOutputDestructor (\r | |
169 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r | |
170 | )\r | |
171 | ;\r | |
172 | \r | |
173 | \r | |
174 | //\r | |
175 | // EFI_DRIVER_BINDING_PROTOCOL Protocol Interface\r | |
176 | //\r | |
177 | /**\r | |
178 | TODO: Add function description\r | |
179 | \r | |
180 | @param This TODO: add argument description\r | |
181 | @param Controller TODO: add argument description\r | |
182 | @param RemainingDevicePath TODO: add argument description\r | |
183 | \r | |
184 | TODO: add return values\r | |
185 | \r | |
186 | **/\r | |
187 | EFI_STATUS\r | |
188 | EFIAPI\r | |
189 | CirrusLogic5430ControllerDriverSupported (\r | |
190 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
191 | IN EFI_HANDLE Controller,\r | |
192 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
193 | )\r | |
194 | ;\r | |
195 | \r | |
196 | /**\r | |
197 | TODO: Add function description\r | |
198 | \r | |
199 | @param This TODO: add argument description\r | |
200 | @param Controller TODO: add argument description\r | |
201 | @param RemainingDevicePath TODO: add argument description\r | |
202 | \r | |
203 | TODO: add return values\r | |
204 | \r | |
205 | **/\r | |
206 | EFI_STATUS\r | |
207 | EFIAPI\r | |
208 | CirrusLogic5430ControllerDriverStart (\r | |
209 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
210 | IN EFI_HANDLE Controller,\r | |
211 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
212 | )\r | |
213 | ;\r | |
214 | \r | |
215 | /**\r | |
216 | TODO: Add function description\r | |
217 | \r | |
218 | @param This TODO: add argument description\r | |
219 | @param Controller TODO: add argument description\r | |
220 | @param NumberOfChildren TODO: add argument description\r | |
221 | @param ChildHandleBuffer TODO: add argument description\r | |
222 | \r | |
223 | TODO: add return values\r | |
224 | \r | |
225 | **/\r | |
226 | EFI_STATUS\r | |
227 | EFIAPI\r | |
228 | CirrusLogic5430ControllerDriverStop (\r | |
229 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
230 | IN EFI_HANDLE Controller,\r | |
231 | IN UINTN NumberOfChildren,\r | |
232 | IN EFI_HANDLE *ChildHandleBuffer\r | |
233 | )\r | |
234 | ;\r | |
235 | \r | |
236 | //\r | |
237 | // EFI Component Name Functions\r | |
238 | //\r | |
239 | /**\r | |
240 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
241 | \r | |
242 | This function retrieves the user readable name of a driver in the form of a\r | |
243 | Unicode string. If the driver specified by This has a user readable name in\r | |
244 | the language specified by Language, then a pointer to the driver name is\r | |
245 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
246 | by This does not support the language specified by Language,\r | |
247 | then EFI_UNSUPPORTED is returned.\r | |
248 | \r | |
249 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
250 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
251 | \r | |
252 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
253 | array indicating the language. This is the\r | |
254 | language of the driver name that the caller is\r | |
255 | requesting, and it must match one of the\r | |
256 | languages specified in SupportedLanguages. The\r | |
257 | number of languages supported by a driver is up\r | |
258 | to the driver writer. Language is specified\r | |
259 | in RFC 3066 or ISO 639-2 language code format.\r | |
260 | \r | |
261 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
262 | This Unicode string is the name of the\r | |
263 | driver specified by This in the language\r | |
264 | specified by Language.\r | |
265 | \r | |
266 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
267 | This and the language specified by Language was\r | |
268 | returned in DriverName.\r | |
269 | \r | |
270 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
271 | \r | |
272 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
273 | \r | |
274 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
275 | the language specified by Language.\r | |
276 | \r | |
277 | **/\r | |
278 | EFI_STATUS\r | |
279 | EFIAPI\r | |
280 | CirrusLogic5430ComponentNameGetDriverName (\r | |
281 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
282 | IN CHAR8 *Language,\r | |
283 | OUT CHAR16 **DriverName\r | |
284 | );\r | |
285 | \r | |
286 | \r | |
287 | /**\r | |
288 | Retrieves a Unicode string that is the user readable name of the controller\r | |
289 | that is being managed by a driver.\r | |
290 | \r | |
291 | This function retrieves the user readable name of the controller specified by\r | |
292 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
293 | driver specified by This has a user readable name in the language specified by\r | |
294 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
295 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
296 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
297 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
298 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
299 | \r | |
300 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
301 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
302 | \r | |
303 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
304 | specified by This is managing. This handle\r | |
305 | specifies the controller whose name is to be\r | |
306 | returned.\r | |
307 | \r | |
308 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
309 | the name of. This is an optional parameter that\r | |
310 | may be NULL. It will be NULL for device\r | |
311 | drivers. It will also be NULL for a bus drivers\r | |
312 | that wish to retrieve the name of the bus\r | |
313 | controller. It will not be NULL for a bus\r | |
314 | driver that wishes to retrieve the name of a\r | |
315 | child controller.\r | |
316 | \r | |
317 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
318 | array indicating the language. This is the\r | |
319 | language of the driver name that the caller is\r | |
320 | requesting, and it must match one of the\r | |
321 | languages specified in SupportedLanguages. The\r | |
322 | number of languages supported by a driver is up\r | |
323 | to the driver writer. Language is specified in\r | |
324 | RFC 3066 or ISO 639-2 language code format.\r | |
325 | \r | |
326 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
327 | This Unicode string is the name of the\r | |
328 | controller specified by ControllerHandle and\r | |
329 | ChildHandle in the language specified by\r | |
330 | Language from the point of view of the driver\r | |
331 | specified by This.\r | |
332 | \r | |
333 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
334 | the language specified by Language for the\r | |
335 | driver specified by This was returned in\r | |
336 | DriverName.\r | |
337 | \r | |
338 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
339 | \r | |
340 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
341 | EFI_HANDLE.\r | |
342 | \r | |
343 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
344 | \r | |
345 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
346 | \r | |
347 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
348 | managing the controller specified by\r | |
349 | ControllerHandle and ChildHandle.\r | |
350 | \r | |
351 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
352 | the language specified by Language.\r | |
353 | \r | |
354 | **/\r | |
355 | EFI_STATUS\r | |
356 | EFIAPI\r | |
357 | CirrusLogic5430ComponentNameGetControllerName (\r | |
358 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
359 | IN EFI_HANDLE ControllerHandle,\r | |
360 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
361 | IN CHAR8 *Language,\r | |
362 | OUT CHAR16 **ControllerName\r | |
363 | );\r | |
364 | \r | |
365 | \r | |
366 | //\r | |
367 | // Local Function Prototypes\r | |
368 | //\r | |
369 | VOID\r | |
370 | InitializeGraphicsMode (\r | |
371 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
372 | CIRRUS_LOGIC_5430_VIDEO_MODES *ModeData\r | |
373 | );\r | |
374 | \r | |
375 | VOID\r | |
376 | SetPaletteColor (\r | |
377 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
378 | UINTN Index,\r | |
379 | UINT8 Red,\r | |
380 | UINT8 Green,\r | |
381 | UINT8 Blue\r | |
382 | );\r | |
383 | \r | |
384 | VOID\r | |
385 | SetDefaultPalette (\r | |
386 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r | |
387 | );\r | |
388 | \r | |
389 | VOID\r | |
390 | DrawLogo (\r | |
391 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
392 | UINTN ScreenWidth,\r | |
393 | UINTN ScreenHeight\r | |
394 | );\r | |
395 | \r | |
396 | VOID\r | |
397 | outb (\r | |
398 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
399 | UINTN Address,\r | |
400 | UINT8 Data\r | |
401 | );\r | |
402 | \r | |
403 | VOID\r | |
404 | outw (\r | |
405 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
406 | UINTN Address,\r | |
407 | UINT16 Data\r | |
408 | );\r | |
409 | \r | |
410 | UINT8\r | |
411 | inb (\r | |
412 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
413 | UINTN Address\r | |
414 | );\r | |
415 | \r | |
416 | UINT16\r | |
417 | inw (\r | |
418 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
419 | UINTN Address\r | |
420 | );\r | |
421 | \r | |
31f9e631 | 422 | EFI_STATUS\r |
423 | CirrusLogic5430VideoModeSetup (\r | |
424 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r | |
425 | );\r | |
426 | \r | |
87f8ccbe | 427 | #endif\r |