3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
16 Initialization for the board ID.
18 This code should be common across a chipset family of products.
25 #include "PlatformDxe.h"
26 #include <Guid/IdccData.h>
27 #include <Guid/EfiVpdData.h>
28 #include <Protocol/DataHub.h>
31 extern EFI_GUID mPlatformDriverGuid
;
38 EFI_BOARD_FEATURES mBoardFeatures
;
39 UINT16 mSubsystemDeviceId
;
40 UINT16 mSubsystemAudioDeviceId
;
41 CHAR8 BoardAaNumber
[7];
46 Write the boardid variable if it does not already exist.
54 UINT32 BoardIdBufferSize
;
55 EFI_IDCC_BOARD_FORM_FACTOR IdccBoardFormFactor
;
56 EFI_DATA_HUB_PROTOCOL
*DataHub
;
58 DMI_DATA DmiDataVariable
;
60 #if defined(DUPLICATE_AA_NO_BASE_ADDR)
61 CHAR8 DuplicateAaNoAscii
[sizeof(DmiDataVariable
.BaseBoardVersion
)];
64 #if defined(GPIO_BOARD_ID_SUPPORT) && GPIO_BOARD_ID_SUPPORT != 0
69 // Update data from the updatable DMI data area
71 Size
= sizeof (DMI_DATA
);
72 SetMem(&DmiDataVariable
, Size
, 0xFF);
73 Status
= gRT
->GetVariable (
81 #if defined(DUPLICATE_AA_NO_BASE_ADDR)
83 // Get AA# from flash descriptor region
85 EfiSetMem(DuplicateAaNoAscii
, sizeof(DuplicateAaNoAscii
), 0xFF);
86 FlashRead((UINT8
*)(UINTN
)DUPLICATE_AA_NO_BASE_ADDR
,
87 (UINT8
*)DuplicateAaNoAscii
,
88 sizeof(DuplicateAaNoAscii
));
91 // Validate AA# read from VPD
93 for (iter
= 0; iter
< sizeof(DuplicateAaNoAscii
); iter
++) {
94 if ((DuplicateAaNoAscii
[iter
] != 0xFF) &&
95 (DuplicateAaNoAscii
[iter
] != DmiDataVariable
.BaseBoardVersion
[iter
])) {
96 DmiDataVariable
.BaseBoardVersion
[iter
] = DuplicateAaNoAscii
[iter
];
100 Status
= EFI_SUCCESS
;
106 // No variable...no copy
108 if (EFI_ERROR (Status
)) {
109 mBoardIdIndex
= 0; // If we can't find the BoardId in the table, use the first entry
112 // This is the correct method of checking for AA#.
114 CopyMem(&BoardAaNumber
, ((((UINT8
*)&DmiDataVariable
.BaseBoardVersion
)+2)), 6);
115 BoardAaNumber
[6] = 0;
116 for (mBoardIdIndex
= 0; mBoardIdIndex
< mBoardIdDecodeTableSize
; mBoardIdIndex
++) {
117 if (AsciiStrnCmp(mBoardIdDecodeTable
[mBoardIdIndex
].AaNumber
, BoardAaNumber
, 6) == 0) {
125 // Add check for AA#'s that is programmed without the AA as leading chars.
127 CopyMem(&BoardAaNumber
, (((UINT8
*)&DmiDataVariable
.BaseBoardVersion
)), 6);
128 BoardAaNumber
[6] = 0;
129 for (mBoardIdIndex
= 0; mBoardIdIndex
< mBoardIdDecodeTableSize
; mBoardIdIndex
++) {
130 if (AsciiStrnCmp(mBoardIdDecodeTable
[mBoardIdIndex
].AaNumber
, BoardAaNumber
, 6) == 0) {
138 #if defined(GPIO_BOARD_ID_SUPPORT) && GPIO_BOARD_ID_SUPPORT != 0
140 // If we can't find the BoardAA# in the table, find BoardId
142 if (mFoundAANum
!= TRUE
) {
144 // BoardID BIT Location
148 Data8
= IoRead8(GPIO_BASE_ADDRESS
+ R_PCH_GPIO_SC_LVL2
);
153 mBoardId
= (UINT32
)((Data8
>> 1) & BIT0
);
157 mBoardId
|= (UINT32
)((Data8
>> 1) & BIT1
);
159 for (mBoardIdIndex
= 0; mBoardIdIndex
< mBoardIdDecodeTableSize
; mBoardIdIndex
++) {
160 if (mBoardIdDecodeTable
[mBoardIdIndex
].BoardId
== mBoardId
) {
165 if (mBoardIdIndex
== mBoardIdDecodeTableSize
) {
166 mBoardIdIndex
= 0; // If we can't find the BoardId in the table, use the first entry
168 #if defined(GPIO_BOARD_ID_SUPPORT) && GPIO_BOARD_ID_SUPPORT != 0
172 mBoardFeatures
= mBoardIdDecodeTable
[mBoardIdIndex
].Features
;
173 mSubsystemDeviceId
= mBoardIdDecodeTable
[mBoardIdIndex
].SubsystemDeviceId
;
174 mSubsystemAudioDeviceId
= mBoardIdDecodeTable
[mBoardIdIndex
].AudioSubsystemDeviceId
;
177 // Set the BoardFeatures variable
179 BoardIdBufferSize
= sizeof (mBoardFeatures
);
182 &gEfiBoardFeaturesGuid
,
183 EFI_VARIABLE_NON_VOLATILE
|
184 EFI_VARIABLE_BOOTSERVICE_ACCESS
|
185 EFI_VARIABLE_RUNTIME_ACCESS
,
191 // Get the Data Hub protocol
193 Status
= gBS
->LocateProtocol (
194 &gEfiDataHubProtocolGuid
,
198 if (!(EFI_ERROR(Status
))) {
202 IdccBoardFormFactor
.IdccHeader
.Type
= EFI_IDCC_BOARD_FORM_FACTOR_TYPE
;
203 IdccBoardFormFactor
.IdccHeader
.RecordLength
= sizeof(EFI_IDCC_BOARD_FORM_FACTOR
);
204 if ((mBoardFeatures
& B_BOARD_FEATURES_FORM_FACTOR_ATX
) || (mBoardFeatures
& B_BOARD_FEATURES_FORM_FACTOR_MICRO_ATX
)) {
205 IdccBoardFormFactor
.BoardFormFactor
= ATX_FORM_FACTOR
; // ATX
207 IdccBoardFormFactor
.BoardFormFactor
= BTX_FORM_FACTOR
; // BTX
211 // Publish the Board Form Factor value for IDCC
213 Status
= DataHub
->LogData (
216 &mPlatformDriverGuid
,
217 EFI_DATA_RECORD_CLASS_DATA
,
218 &IdccBoardFormFactor
,
219 sizeof(EFI_IDCC_BOARD_FORM_FACTOR
)