]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2TbltDevicePkg / Library / PchPlatformLib / PchPlatformLibrary.c
1 /**
2
3 Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved
4
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13
14 @file
15 PchPlatformLib.c
16
17 @brief
18 PCH Platform Lib implementation.
19
20 **/
21
22 #include "PchPlatformLibrary.h"
23
24 //
25 // Silicon Steppings
26 //
27 /**
28 Return Pch stepping type
29
30 @param[in] None
31
32 @retval PCH_STEPPING Pch stepping type
33
34 **/
35 PCH_STEPPING
36 EFIAPI
37 PchStepping (
38 VOID
39 )
40 {
41 UINT8 RevId;
42
43 RevId = MmioRead8 (
44 MmPciAddress (0,
45 DEFAULT_PCI_BUS_NUMBER_PCH,
46 PCI_DEVICE_NUMBER_PCH_LPC,
47 PCI_FUNCTION_NUMBER_PCH_LPC,
48 R_PCH_LPC_RID_CC)
49 );
50
51 switch (RevId) {
52 case V_PCH_LPC_RID_0:
53 case V_PCH_LPC_RID_1:
54 return PchA0;
55 break;
56
57 case V_PCH_LPC_RID_2:
58 case V_PCH_LPC_RID_3:
59 return PchA1;
60 break;
61
62 case V_PCH_LPC_RID_4:
63 case V_PCH_LPC_RID_5:
64 return PchB0;
65 break;
66
67 case V_PCH_LPC_RID_6:
68 case V_PCH_LPC_RID_7:
69 return PchB1;
70 break;
71
72 case V_PCH_LPC_RID_8:
73 case V_PCH_LPC_RID_9:
74 return PchB2;
75 break;
76
77 case V_PCH_LPC_RID_A:
78 case V_PCH_LPC_RID_B:
79 return PchB3;
80 break;
81
82 case V_PCH_LPC_RID_C:
83 case V_PCH_LPC_RID_D:
84 return PchC0;
85 break;
86
87 default:
88 return PchSteppingMax;
89 break;
90
91 }
92 }
93
94 /**
95 Determine if PCH is supported
96
97 @param[in] None
98
99 @retval TRUE PCH is supported
100 @retval FALSE PCH is not supported
101
102 **/
103 BOOLEAN
104 IsPchSupported (
105 VOID
106 )
107 {
108 UINT32 Identifiers;
109 UINT16 PcuVendorId;
110 UINT16 PcuDeviceId;
111
112 Identifiers = MmioRead32 (
113 MmPciAddress (0,
114 DEFAULT_PCI_BUS_NUMBER_PCH,
115 PCI_DEVICE_NUMBER_PCH_LPC,
116 PCI_FUNCTION_NUMBER_PCH_LPC,
117 R_PCH_LPC_REG_ID)
118 );
119
120 PcuDeviceId = (UINT16) ((Identifiers & B_PCH_LPC_DEVICE_ID) >> 16);
121 PcuVendorId = (UINT16) (Identifiers & B_PCH_LPC_VENDOR_ID);
122
123 //
124 // Verify that this is a supported chipset
125 //
126 if (PcuVendorId != (UINT16) V_PCH_LPC_VENDOR_ID || !IS_PCH_VLV_LPC_DEVICE_ID (PcuDeviceId)) {
127 DEBUG ((EFI_D_ERROR, "VLV SC code doesn't support the PcuDeviceId: 0x%04x!\n", PcuDeviceId));
128 return FALSE;
129 }
130 return TRUE;
131 }