3 Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Lib to provide LED status code reporting Routines.
20 In general you should use PPI's, but some times a monolithic driver
21 is better. The best justification for monolithic code is debug.
25 #include "RtLedStatusCode.h"
28 // Prepare the data to initialize LPC chipset for Server Io Configuration
29 // This is hardcoded init value and would vary from platform to platform.
31 static SIO_INIT_DATA mSioInitData
[] = {
33 // Program magic values in ServerI/O configuration registers
52 // Force the parallel port to be disabled, override reg 30 setting
59 // Select GPIO device and setup GPIO base address
82 // Select DLED STB, post code LED, ZZ_POST_CLK_LED_L
89 // Push pull output enable
93 PUSH_PULL
| OUTPUT_BUFFER_EN
96 // Disable Event IRQ routing
103 // Select DLED STB, ZZ_POST_DATA_LED_L
110 // Push pull output enable
114 PUSH_PULL
| OUTPUT_BUFFER_EN
117 // Disable Event IRQ routing
124 // Select Select ACPI_MODE_IND_L
131 // Push pull output enable
135 PUSH_PULL
| OUTPUT_BUFFER_EN
145 RtLedInitializeStatusCode (
146 IN EFI_HANDLE ImageHandle
,
147 IN EFI_SYSTEM_TABLE
*SystemTable
153 Initialization routine. Initializes LPC47817 to configure GPIO for LED
171 // hard code for sio init
173 ConfigPort
= CONFIG_PORT0
;
174 DataPort
= DATA_PORT0
;
177 // Initialize Sio from table to enable SererIoCfg and GPIO
180 while ((mSioInitData
[Index
]).RegAddress
!= 0xff) {
181 OutputData
= (UINT8
) mSioInitData
[Index
].RegAddress
;
183 IoWrite8 (ConfigPort
, OutputData
);
185 OutputData
= (UINT8
) mSioInitData
[Index
].RegValue
;
186 IoWrite8 (DataPort
, OutputData
);
195 CodeTypeToProgressCode (
196 IN EFI_STATUS_CODE_TYPE CodeType
,
197 IN EFI_STATUS_CODE_VALUE Value
,
202 // Convert Value to an 8 bit post code
204 if (((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
)) {
205 *PostCode
= (UINT8
) (((Value
& EFI_STATUS_CODE_CLASS_MASK
) >> 24) << 5);
206 *PostCode
= (UINT8
) (*PostCode
| (UINT8
) (((Value
& EFI_STATUS_CODE_SUBCLASS_MASK
) >> 16) & 0x1f));
222 Writes the data to control LED output at desired port
226 Data - Data in bit0 is the relevant data
227 DataOffset - Port address to access GPIO54
238 // Read current Pin State of GPIO54
240 PinData
= IoRead8 (DataOffset
);
243 // Set GPIO54 pin to zero
249 // Set GPIO54 pin to 1 if data is 1
250 // otherwise it will be set to 0
252 PinData
|= LED_MASK_BIT
;
255 IoWrite8 (DataOffset
, PinData
);
260 IN UINT16 StrobeOffset
266 Controls the strobe to move the value from LSB to MSB in steps.
270 StrobeOffset - Port address to access GPIO43. This pin controls the shifting
271 of bit value from LSB to MSB
281 StrobeData
= IoRead8 (StrobeOffset
);
284 // Make bit 3 of data to be zero
288 IoWrite8 (StrobeOffset
, StrobeData
);
291 // Make bit 3 as 1 to perform the strobe to shift the data in 74HCT164
293 StrobeData
|= STROBE_MASK_BIT
;
295 IoWrite8 (StrobeOffset
, StrobeData
);
307 UINTN DataBitPosition
;
310 GpioBase
= GPIO_BASE (SIO_GPIO_HIGH
, SIO_GPIO_LOW
);
312 DataOffset
= (UINT16
) (GpioBase
+ LED_DATA_OFFSET
);
314 StrobeOffset
= (UINT16
) (GpioBase
+ LED_STROBE_OFFSET
);
318 Data
= (UINT8
) (~Data
);
322 for (Index
= 0; Index
< 8; Index
++) {
323 SendDataToPort ((UINT8
) (TempData
>> DataBitPosition
), DataOffset
);
324 StrobeData (StrobeOffset
);
328 // To fix 5 Volt leakage problem
330 SendDataToPort (0, DataOffset
);
335 RtLedReportStatusCode (
336 IN EFI_STATUS_CODE_TYPE CodeType
,
337 IN EFI_STATUS_CODE_VALUE Value
,
339 IN EFI_GUID
* CallerId
,
340 IN EFI_STATUS_CODE_DATA
* Data OPTIONAL
346 Provide a LED status code
350 Same as ReportStatusCode PPI
354 Status - EFI_SUCCESS if the interface could be successfully
361 if (CodeTypeToProgressCode (CodeType
, Value
, &ProgressCode
)) {
362 SendDataToLed (ProgressCode
);