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