Add code to identify D0 stepping ValleyView SoC.
[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 case V_PCH_LPC_RID_E:
88 case V_PCH_LPC_RID_F:
89 return PchD0;
90 break;
91
92 default:
93 return PchSteppingMax;
94 break;
95
96 }
97 }
98
99 /**
100 Determine if PCH is supported
101
102 @param[in] None
103
104 @retval TRUE PCH is supported
105 @retval FALSE PCH is not supported
106
107 **/
108 BOOLEAN
109 IsPchSupported (
110 VOID
111 )
112 {
113 UINT32 Identifiers;
114 UINT16 PcuVendorId;
115 UINT16 PcuDeviceId;
116
117 Identifiers = MmioRead32 (
118 MmPciAddress (0,
119 DEFAULT_PCI_BUS_NUMBER_PCH,
120 PCI_DEVICE_NUMBER_PCH_LPC,
121 PCI_FUNCTION_NUMBER_PCH_LPC,
122 R_PCH_LPC_REG_ID)
123 );
124
125 PcuDeviceId = (UINT16) ((Identifiers & B_PCH_LPC_DEVICE_ID) >> 16);
126 PcuVendorId = (UINT16) (Identifiers & B_PCH_LPC_VENDOR_ID);
127
128 //
129 // Verify that this is a supported chipset
130 //
131 if (PcuVendorId != (UINT16) V_PCH_LPC_VENDOR_ID || !IS_PCH_VLV_LPC_DEVICE_ID (PcuDeviceId)) {
132 DEBUG ((EFI_D_ERROR, "VLV SC code doesn't support the PcuDeviceId: 0x%04x!\n", PcuDeviceId));
133 return FALSE;
134 }
135 return TRUE;
136 }