]>
Commit | Line | Data |
---|---|---|
b38907a6 | 1 | /*++\r |
2 | \r | |
4b1e1121 HT |
3 | Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r |
4 | This program and the accompanying materials \r | |
b38907a6 | 5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | RtLedStatusCode.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Lib to provide LED status code reporting Routines.\r | |
19 | \r | |
20 | In general you should use PPI's, but some times a monolithic driver\r | |
21 | is better. The best justification for monolithic code is debug.\r | |
22 | \r | |
23 | --*/\r | |
24 | \r | |
25 | #include "RtLedStatusCode.h"\r | |
26 | \r | |
27 | //\r | |
28 | // Prepare the data to initialize LPC chipset for Server Io Configuration\r | |
29 | // This is hardcoded init value and would vary from platform to platform.\r | |
30 | //\r | |
31 | static SIO_INIT_DATA mSioInitData[] = {\r | |
32 | //\r | |
33 | // Program magic values in ServerI/O configuration registers\r | |
34 | //\r | |
35 | {\r | |
36 | REG_SERVERIO_CNF1,\r | |
37 | 0x19\r | |
38 | },\r | |
39 | {\r | |
40 | REG_SERVERIO_CNF2,\r | |
41 | 0x22\r | |
42 | },\r | |
43 | {\r | |
44 | REG_SERVERIO_CNF3,\r | |
45 | 0x76\r | |
46 | },\r | |
47 | {\r | |
48 | REG_SERVERIO_CNF4,\r | |
49 | 0x26\r | |
50 | },\r | |
51 | //\r | |
52 | // Force the parallel port to be disabled, override reg 30 setting\r | |
53 | //\r | |
54 | {\r | |
55 | REG_SERVERIO_CNF6,\r | |
56 | 0x02\r | |
57 | },\r | |
58 | //\r | |
59 | // Select GPIO device and setup GPIO base address\r | |
60 | //\r | |
61 | {\r | |
62 | REG_LOGICAL_DEVICE,\r | |
63 | SIO_GPIO\r | |
64 | },\r | |
65 | {\r | |
66 | ACTIVATE,\r | |
67 | LOGICAL_DEVICE_OFF\r | |
68 | },\r | |
69 | {\r | |
70 | BASE_ADDRESS_HIGH,\r | |
71 | SIO_GPIO_HIGH\r | |
72 | },\r | |
73 | {\r | |
74 | BASE_ADDRESS_LOW,\r | |
75 | SIO_GPIO_LOW\r | |
76 | },\r | |
77 | {\r | |
78 | ACTIVATE,\r | |
79 | LOGICAL_DEVICE_ON\r | |
80 | },\r | |
81 | //\r | |
82 | // Select DLED STB, post code LED, ZZ_POST_CLK_LED_L\r | |
83 | //\r | |
84 | {\r | |
85 | GPIO_GPSEL,\r | |
86 | 0x43\r | |
87 | },\r | |
88 | //\r | |
89 | // Push pull output enable\r | |
90 | //\r | |
91 | {\r | |
92 | GPIO_GPCFG1,\r | |
93 | PUSH_PULL | OUTPUT_BUFFER_EN\r | |
94 | },\r | |
95 | //\r | |
96 | // Disable Event IRQ routing\r | |
97 | //\r | |
98 | {\r | |
99 | GPIO_GPEVR,\r | |
100 | GPIO_EVENT_OFF\r | |
101 | },\r | |
102 | //\r | |
103 | // Select DLED STB, ZZ_POST_DATA_LED_L\r | |
104 | //\r | |
105 | {\r | |
106 | GPIO_GPSEL,\r | |
107 | 0x54\r | |
108 | },\r | |
109 | //\r | |
110 | // Push pull output enable\r | |
111 | //\r | |
112 | {\r | |
113 | GPIO_GPCFG1,\r | |
114 | PUSH_PULL | OUTPUT_BUFFER_EN\r | |
115 | },\r | |
116 | //\r | |
117 | // Disable Event IRQ routing\r | |
118 | //\r | |
119 | {\r | |
120 | GPIO_GPEVR,\r | |
121 | GPIO_EVENT_OFF\r | |
122 | },\r | |
123 | //\r | |
124 | // Select Select ACPI_MODE_IND_L\r | |
125 | //\r | |
126 | {\r | |
127 | GPIO_GPSEL,\r | |
128 | 0x63\r | |
129 | },\r | |
130 | //\r | |
131 | // Push pull output enable\r | |
132 | //\r | |
133 | {\r | |
134 | GPIO_GPCFG1,\r | |
135 | PUSH_PULL | OUTPUT_BUFFER_EN\r | |
136 | },\r | |
137 | \r | |
138 | {\r | |
139 | 0xff,\r | |
140 | 0xff\r | |
141 | }\r | |
142 | };\r | |
143 | \r | |
144 | VOID\r | |
145 | RtLedInitializeStatusCode (\r | |
146 | IN EFI_HANDLE ImageHandle,\r | |
147 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
148 | )\r | |
149 | /*++\r | |
150 | \r | |
151 | Routine Description:\r | |
152 | \r | |
153 | Initialization routine. Initializes LPC47817 to configure GPIO for LED\r | |
154 | \r | |
155 | Arguments: \r | |
156 | \r | |
157 | None\r | |
158 | \r | |
159 | Returns: \r | |
160 | \r | |
161 | None\r | |
162 | \r | |
163 | --*/\r | |
164 | {\r | |
165 | UINT8 OutputData;\r | |
166 | UINT16 ConfigPort;\r | |
167 | UINT16 DataPort;\r | |
168 | UINT32 Index;\r | |
169 | \r | |
170 | //\r | |
171 | // hard code for sio init\r | |
172 | //\r | |
173 | ConfigPort = CONFIG_PORT0;\r | |
174 | DataPort = DATA_PORT0;\r | |
175 | \r | |
176 | //\r | |
177 | // Initialize Sio from table to enable SererIoCfg and GPIO\r | |
178 | //\r | |
179 | Index = 0;\r | |
180 | while ((mSioInitData[Index]).RegAddress != 0xff) {\r | |
181 | OutputData = (UINT8) mSioInitData[Index].RegAddress;\r | |
182 | \r | |
183 | IoWrite8 (ConfigPort, OutputData);\r | |
184 | \r | |
185 | OutputData = (UINT8) mSioInitData[Index].RegValue;\r | |
186 | IoWrite8 (DataPort, OutputData);\r | |
187 | \r | |
188 | Index++;\r | |
189 | }\r | |
190 | \r | |
191 | return ;\r | |
192 | }\r | |
193 | \r | |
194 | BOOLEAN\r | |
195 | CodeTypeToProgressCode (\r | |
196 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
197 | IN EFI_STATUS_CODE_VALUE Value,\r | |
198 | OUT UINT8 *PostCode\r | |
199 | )\r | |
200 | {\r | |
201 | //\r | |
202 | // Convert Value to an 8 bit post code\r | |
203 | //\r | |
204 | if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE)) {\r | |
205 | *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5);\r | |
6b6f7452 | 206 | *PostCode = (UINT8) (*PostCode | (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));\r |
b38907a6 | 207 | return TRUE;\r |
208 | }\r | |
209 | \r | |
210 | return FALSE;\r | |
211 | }\r | |
212 | \r | |
213 | VOID\r | |
214 | SendDataToPort (\r | |
215 | IN UINT8 Data,\r | |
216 | IN UINT16 DataOffset\r | |
217 | )\r | |
218 | /*++\r | |
219 | \r | |
220 | Routine Description:\r | |
221 | \r | |
222 | Writes the data to control LED output at desired port\r | |
223 | \r | |
224 | Arguments: \r | |
225 | \r | |
226 | Data - Data in bit0 is the relevant data\r | |
227 | DataOffset - Port address to access GPIO54\r | |
228 | \r | |
229 | Returns: \r | |
230 | \r | |
231 | None\r | |
232 | \r | |
233 | --*/\r | |
234 | {\r | |
235 | UINT8 PinData;\r | |
236 | \r | |
237 | //\r | |
238 | // Read current Pin State of GPIO54\r | |
239 | //\r | |
240 | PinData = IoRead8 (DataOffset);\r | |
241 | \r | |
242 | //\r | |
243 | // Set GPIO54 pin to zero\r | |
244 | //\r | |
245 | PinData &= 0xEF;\r | |
246 | \r | |
247 | if (Data & 0x01) {\r | |
248 | //\r | |
249 | // Set GPIO54 pin to 1 if data is 1\r | |
250 | // otherwise it will be set to 0\r | |
251 | //\r | |
252 | PinData |= LED_MASK_BIT;\r | |
253 | }\r | |
254 | \r | |
255 | IoWrite8 (DataOffset, PinData);\r | |
256 | }\r | |
257 | \r | |
258 | VOID\r | |
259 | StrobeData (\r | |
260 | IN UINT16 StrobeOffset\r | |
261 | )\r | |
262 | /*++\r | |
263 | \r | |
264 | Routine Description:\r | |
265 | \r | |
266 | Controls the strobe to move the value from LSB to MSB in steps.\r | |
267 | \r | |
268 | Arguments: \r | |
269 | \r | |
270 | StrobeOffset - Port address to access GPIO43. This pin controls the shifting\r | |
271 | of bit value from LSB to MSB\r | |
272 | \r | |
273 | Returns: \r | |
274 | \r | |
275 | None\r | |
276 | \r | |
277 | --*/\r | |
278 | {\r | |
279 | UINT8 StrobeData;\r | |
280 | \r | |
281 | StrobeData = IoRead8 (StrobeOffset);\r | |
282 | \r | |
283 | //\r | |
284 | // Make bit 3 of data to be zero\r | |
285 | //\r | |
286 | StrobeData &= 0xF7;\r | |
287 | \r | |
288 | IoWrite8 (StrobeOffset, StrobeData);\r | |
289 | \r | |
290 | //\r | |
291 | // Make bit 3 as 1 to perform the strobe to shift the data in 74HCT164\r | |
292 | //\r | |
293 | StrobeData |= STROBE_MASK_BIT;\r | |
294 | \r | |
295 | IoWrite8 (StrobeOffset, StrobeData);\r | |
296 | }\r | |
297 | \r | |
298 | VOID\r | |
299 | SendDataToLed (\r | |
300 | UINT8 Data\r | |
301 | )\r | |
302 | {\r | |
303 | UINT16 GpioBase;\r | |
304 | UINT16 DataOffset;\r | |
305 | UINT16 StrobeOffset;\r | |
306 | UINTN Index;\r | |
307 | UINTN DataBitPosition;\r | |
308 | UINT8 TempData;\r | |
309 | \r | |
310 | GpioBase = GPIO_BASE (SIO_GPIO_HIGH, SIO_GPIO_LOW);\r | |
311 | \r | |
312 | DataOffset = (UINT16) (GpioBase + LED_DATA_OFFSET);\r | |
313 | \r | |
314 | StrobeOffset = (UINT16) (GpioBase + LED_STROBE_OFFSET);\r | |
315 | \r | |
316 | DataBitPosition = 7;\r | |
317 | \r | |
318 | Data = (UINT8) (~Data);\r | |
319 | \r | |
320 | TempData = Data;\r | |
321 | \r | |
322 | for (Index = 0; Index < 8; Index++) {\r | |
323 | SendDataToPort ((UINT8) (TempData >> DataBitPosition), DataOffset);\r | |
324 | StrobeData (StrobeOffset);\r | |
325 | DataBitPosition--;\r | |
326 | }\r | |
327 | //\r | |
328 | // To fix 5 Volt leakage problem\r | |
329 | //\r | |
330 | SendDataToPort (0, DataOffset);\r | |
331 | \r | |
332 | }\r | |
333 | \r | |
334 | EFI_STATUS\r | |
335 | RtLedReportStatusCode (\r | |
336 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
337 | IN EFI_STATUS_CODE_VALUE Value,\r | |
338 | IN UINT32 Instance,\r | |
339 | IN EFI_GUID * CallerId,\r | |
340 | IN EFI_STATUS_CODE_DATA * Data OPTIONAL\r | |
341 | )\r | |
342 | /*++\r | |
343 | \r | |
344 | Routine Description:\r | |
345 | \r | |
346 | Provide a LED status code\r | |
347 | \r | |
348 | Arguments:\r | |
349 | \r | |
350 | Same as ReportStatusCode PPI\r | |
351 | \r | |
352 | Returns:\r | |
353 | \r | |
354 | Status - EFI_SUCCESS if the interface could be successfully\r | |
355 | installed\r | |
356 | \r | |
357 | --*/\r | |
358 | {\r | |
359 | UINT8 ProgressCode;\r | |
360 | \r | |
361 | if (CodeTypeToProgressCode (CodeType, Value, &ProgressCode)) {\r | |
362 | SendDataToLed (ProgressCode);\r | |
363 | }\r | |
364 | \r | |
365 | return EFI_SUCCESS;\r | |
366 | }\r |