ecb6b4344aef38672e432fced370055bbfa9775e
[coreboot.git] / src / vendorcode / amd / agesa / f14 / Proc / GNB / Modules / GnbPcieInitLibV1 / PcieAspmBlackList.c
1 /**
2  * @file
3  *
4  * PCIe link ASPM Black List
5  *
6  *
7  *
8  * @xrefitem bom "File Content Label" "Release Content"
9  * @e project:     AGESA
10  * @e sub-project: GNB
11  * @e \$Revision: 33827 $   @e \$Date: 2010-06-24 22:11:37 +0800 (Thu, 24 Jun 2010) $
12  *
13  */
14 /*
15  *****************************************************************************
16  *
17  * Copyright (c) 2011, Advanced Micro Devices, Inc.
18  * All rights reserved.
19  * 
20  * Redistribution and use in source and binary forms, with or without
21  * modification, are permitted provided that the following conditions are met:
22  *     * Redistributions of source code must retain the above copyright
23  *       notice, this list of conditions and the following disclaimer.
24  *     * Redistributions in binary form must reproduce the above copyright
25  *       notice, this list of conditions and the following disclaimer in the
26  *       documentation and/or other materials provided with the distribution.
27  *     * Neither the name of Advanced Micro Devices, Inc. nor the names of 
28  *       its contributors may be used to endorse or promote products derived 
29  *       from this software without specific prior written permission.
30  * 
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
32  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34  * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
35  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  * 
42  * ***************************************************************************
43  *
44  */
45
46 /*----------------------------------------------------------------------------------------
47  *                             M O D U L E S    U S E D
48  *----------------------------------------------------------------------------------------
49  */
50 #include  "AGESA.h"
51 #include  "Gnb.h"
52 #include  "GnbPcie.h"
53 #include  GNB_MODULE_DEFINITIONS (GnbCommonLib)
54 #include  "PcieAspmBlackList.h"
55 #include  "Filecode.h"
56 #define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIEASPMBLACKLIST_FILECODE
57 /*----------------------------------------------------------------------------------------
58  *                   D E F I N I T I O N S    A N D    M A C R O S
59  *----------------------------------------------------------------------------------------
60  */
61
62
63 /*----------------------------------------------------------------------------------------
64  *                  T Y P E D E F S     A N D     S T R U C T U  R E S
65  *----------------------------------------------------------------------------------------
66  */
67
68 /*----------------------------------------------------------------------------------------
69  *           P R O T O T Y P E S     O F     L O C A L     F U  N C T I O N S
70  *----------------------------------------------------------------------------------------
71  */
72
73
74 UINT16  AspmBrDeviceTable[] = {
75  0x1002, 0x9441, (UINT16) ~(AspmL1 | AspmL0s),
76  0x10B5, 0xFFFF, (UINT16) ~(AspmL1 | AspmL0s),
77  0x10DE, 0x0402, (UINT16) ~(AspmL1 | AspmL0s),
78  0x10DE, 0x0193, (UINT16) ~(AspmL1 | AspmL0s),
79  0x10DE, 0x0422, (UINT16) ~(AspmL1 | AspmL0s),
80  0x10DE, 0x0292, (UINT16) ~(AspmL1 | AspmL0s),
81  0x10DE, 0x00F9, (UINT16) ~(AspmL1 | AspmL0s),
82  0x10DE, 0x0141, (UINT16) ~(AspmL1 | AspmL0s),
83  0x10DE, 0x0092, (UINT16) ~(AspmL1 | AspmL0s),
84  0x10DE, 0x01D0, (UINT16) ~(AspmL1 | AspmL0s),
85  0x10DE, 0x01D1, (UINT16) ~(AspmL1 | AspmL0s),
86  0x10DE, 0x01D2, (UINT16) ~(AspmL1 | AspmL0s),
87  0x10DE, 0x01D3, (UINT16) ~(AspmL1 | AspmL0s),
88  0x10DE, 0x01D5, (UINT16) ~(AspmL1 | AspmL0s),
89  0x10DE, 0x01D7, (UINT16) ~(AspmL1 | AspmL0s),
90  0x10DE, 0x01D8, (UINT16) ~(AspmL1 | AspmL0s),
91  0x10DE, 0x01DC, (UINT16) ~(AspmL1 | AspmL0s),
92  0x10DE, 0x01DE, (UINT16) ~(AspmL1 | AspmL0s),
93  0x10DE, 0x01DF, (UINT16) ~(AspmL1 | AspmL0s),
94  0x10DE, 0x016A, (UINT16) ~(AspmL1 | AspmL0s),
95  0x10DE, 0x0392, (UINT16) ~(AspmL1 | AspmL0s),
96  0x168C, 0xFFFF, (UINT16) ~(AspmL0s),
97  0x1B4B, 0x91A3, (UINT16) ~(AspmL0s)
98 };
99
100 /*----------------------------------------------------------------------------------------*/
101 /**
102  * Pcie ASPM Black List
103  *
104  *
105  *
106  * @param[in] LinkAsmp            PCie ASPM black list
107  * @param[in] StdHeader           Standard configuration header
108  * @retval     AGESA_STATUS
109  */
110
111 AGESA_STATUS
112 PcieAspmBlackListFeature (
113   IN       PCIe_LINK_ASPM         *LinkAsmp,
114   IN       AMD_CONFIG_PARAMS      *StdHeader
115   )
116 {
117   UINT32  UpstreamDeviceId;
118   UINT32  DownstreamDeviceId;
119   UINTN   i;
120   GnbLibPciRead (LinkAsmp->UpstreamPort.AddressValue, AccessWidth32, &UpstreamDeviceId, StdHeader);
121   GnbLibPciRead (LinkAsmp->DownstreamPort.AddressValue, AccessWidth32, &DownstreamDeviceId, StdHeader);
122   for (i = 0; i < (sizeof (AspmBrDeviceTable) / sizeof (UINT16)); i = i + 3) {
123     UINT32 DeviceId;
124     UINT32 VendorId;
125     VendorId = AspmBrDeviceTable[i];
126     DeviceId = AspmBrDeviceTable[i + 1];
127     if (VendorId == (UINT16)UpstreamDeviceId || VendorId == (UINT16)DownstreamDeviceId ) {
128       if (DeviceId == 0xFFFF || DeviceId == (UpstreamDeviceId >> 16) || DeviceId == (DownstreamDeviceId >> 16)) {
129         LinkAsmp->UpstreamAspm &= AspmBrDeviceTable[i + 2];
130         LinkAsmp->DownstreamAspm &= AspmBrDeviceTable[i + 2];
131       }
132     }
133   }
134   if ((UINT16)UpstreamDeviceId == 0x168c) {
135     // Atheros (Ignore dev capability enable L1 if requested)
136     LinkAsmp->UpstreamAspm = LinkAsmp->RequestedAspm & AspmL1;
137     LinkAsmp->DownstreamAspm = LinkAsmp->UpstreamAspm;
138     GnbLibPciRMW (LinkAsmp->UpstreamPort.AddressValue | 0x70C, AccessS3SaveWidth32, 0x0, 0x0F003F01, StdHeader);
139   }
140   return AGESA_SUCCESS;
141 }